package com.banmao.algorithm.No201To300.No203;

import java.util.Random;

public class Answer {

    public static void main(String[] args) {
        Solution1 solution1 = new Solution1();

        ListNode head = new ListNode(10);
        generateList(head);

        printNodeList(head);

        ListNode res = solution1.removeElements(head, 10);
        printNodeList(res);
    }

    private static void printNodeList(ListNode head) {
        ListNode cur = head;
        StringBuffer sb = new StringBuffer("[");
        while(cur != null) {
            sb.append(cur.val + ", ");
            cur = cur.next;
        }
        sb.replace(sb.lastIndexOf(","), sb.length() - 1, "]");
        System.out.println(sb);
    }


    public static void generateList(ListNode head) {

        Random random = new Random();

        ListNode cur = head;

        for (int i = 0; i < 10; i++) {
            int val = random.nextInt(5);
            ListNode node = new ListNode(val);
            cur.next = node;
            cur = cur.next;
        }

    }

}
